/****************************************************************
 * Fulguro
 * Copyright (C) 2004 Christophe Clienti
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 ***************************************************************/


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <flgrCoreData.h>
#include <flgrCoreCopy.h>
#include <flgrCoreMalloc.h>
#include <flgrCoreNhbManage.h>
#include <flgrCoreDispatch.h>
#include <flgrCoreTypes.h>
#include "flgrMorphoGolay.h"

/*!
 * \defgroup group_fulguro_core_morpho_hom Hit or miss operations
 * \ingroup group_fulguro_morpho
 * \brief Hit or miss operations
 * @{
 */
/*

Serra and Soille said that I : 1 1 1
                               1 2 1
                               1 1 1

  * * *
  * * *
  * * *
  h(0,1)

  o o o
  o o o
  o o o
  i(0,1)

  . . .    o o .    o o o    . o o 
  o * o    o * .    o * o    . * o 
  o o o    o o .    . . .    . o o 
  e(0,1)   e(2,3)   e(4,5)   e(6,7)

             o                 *                 *                  o    
  o o o    . . o    * . o    * . .    * * *    . . *    o . *     o . .  
  . * .  * . * . o  * * o  * . * . o  . * .  o . * . *  o * *   o . *   *
  * * *    * . .    * . o    . . o    o o o    o . .    o . *     . . *  
             *                 o                 o                  *    
  l(0,1)  l(2,3)    l(4,5)  l(6,7)    l(8,9) l(10,11)  l(12,13) l(14,15) 

             *                 *                 .                  .    
  * . .    * . .    * * *    . . *    . . *    o . .    . o .     . . o  
  * * o  * . * . .  . * .  . . * . *  o * *  . . * . *  . * .   * . * . .
  * . .    . . o    . o .    o . .    . . *    . . *    * * *     * . .  
             .                 .                 *                  *    
  m(0,1)  m(2,3)    m(4,5)  m(6,7)    m(8,9) m(10,11)  m(12,13) m(14,15) 

             o                 o                 .                  .    
  o . .    o . .    o o o    . . o    . . o    * . .    . * .     . . *  
  o * *  o . * . .  . * .  . . * . o  * * o  . . * . o  . * .   o . * . .
  o . .    . . *    . * .    * . .    . . o    . . o    o o o     o . .  
             .                 .                 o                  o    
  d(0,1)  d(2,3)    d(4,5)  d(6,7)    d(8,9) d(10,11)  d(12,13) d(14,15) 

             *                 *                 o                  o    
  * o o    o * o    * o *    o * o    o o *    * . o    o * o     o . *  
  o * *  * * * . o  o * o  o . * * *  * * o  o . * * *  o * o   * * * . o
  * o o    o . *    o * o    * . o    o o *    o * o    * o *     o * o  
             o                 o                 *                  *    
  f(0,1)  f(2,3)    f(4,5)  f(6,7)    f(8,9) f(10,11)  f(12,13) f(14,15) 

             *                 o                 o                  *     
  * * *    o . *    o o *    o . o    o o o    o . o    * o o     * . o   
  o * o  o . * . *  o * *  o . * . *  o * o  * . * . o  * * o   * . * . o 
  o o o    o . o    o o *    o . *    * * *    * . o    * o o     o . o  
             o                 *                 *                  o    
  f2(0,1) f2(2,3)  f2(4,5)  f2(6,7)  f2(8,9) f2(10,11)f2(12,13) f2(14,15)

             *                 .                 .                  o    
  * * o    . . *    . . *    . . .    . . .    . . .    o . .     * . .  
  . * .  . . * . o  . * *  . . * . *  . * .  o . * . .  * * .   * . * . .
  . . .    . . .    . . o    . . *    o * *    * . .    * . .     . . .  
             .                 o                 *                  .    
  k(0,1)  k(2,3)    k(4,5)  k(6,7)    k(8,9) k(10,11)  k(12,13) k(14,15) 

  * . .      *      * * *      *      . . *      .      . . .       .    
  * o .    * . .    . o .    . . *    . o *    . . .    . o .     . . .  
  * . .  * . o . .  . . .  . . o . *  . . *  . . o   *  * * *   *   o . .
           . . .             . . .             . . *              * . .  
             .                 .                 *                  *    
  c(0,1)  c(2,3)    c(4,5)  c(6,7)    c(8,9) c(10,11)  c(12,13) c(14,15) 

*/

/////////////////////////////////////////////////////////////
// SQUARE GRID : GOLAY L
/////////////////////////////////////////////////////////////
#define GOLAY_SQ_L_0(VAR)			\
  VAR[9]={2,2,2,				\
	  0,2,0,				\
	  1,1,1}

#define GOLAY_SQ_L_1(VAR)			\
  VAR[9]={0,2,0,				\
	  1,2,2,				\
	  1,1,0}

#define GOLAY_SQ_L_2(VAR)			\
  VAR[9]={1,0,2,				\
	  1,2,2,				\
	  1,0,2}

#define GOLAY_SQ_L_3(VAR)			\
  VAR[9]={1,1,0,				\
	  1,2,2,				\
	  0,2,0}

#define GOLAY_SQ_L_4(VAR)			\
  VAR[9]={1,1,1,				\
	  0,2,0,				\
	  2,2,2}

#define GOLAY_SQ_L_5(VAR)			\
  VAR[9]={0,1,1,				\
	  2,2,1,				\
	  0,2,0}

#define GOLAY_SQ_L_6(VAR)			\
  VAR[9]={2,0,1,				\
	  2,2,1,				\
	  2,0,1}

#define GOLAY_SQ_L_7(VAR)			\
  VAR[9]={0,2,0,				\
	  2,2,1,				\
	  0,1,1}


/////////////////////////////////////////////////////////////
// SQUARE GRID : GOLAY M
/////////////////////////////////////////////////////////////
#define GOLAY_SQ_M_0(VAR)			\
  VAR[9]={2,2,2,				\
	  0,2,0,				\
	  0,1,0}

#define GOLAY_SQ_M_1(VAR)			\
  VAR[9]={0,2,0,				\
	  0,2,2,				\
	  1,0,0}

#define GOLAY_SQ_M_2(VAR)			\
  VAR[9]={0,0,2,				\
	  1,2,2,				\
	  0,0,2}

#define GOLAY_SQ_M_3(VAR)			\
  VAR[9]={1,0,0,				\
	  0,2,2,				\
	  0,2,0}

#define GOLAY_SQ_M_4(VAR)			\
  VAR[9]={0,1,0,				\
	  0,2,0,				\
	  2,2,2}

#define GOLAY_SQ_M_5(VAR)			\
  VAR[9]={0,0,1,				\
	  2,2,0,				\
	  0,2,0}

#define GOLAY_SQ_M_6(VAR)			\
  VAR[9]={2,0,0,				\
	  2,2,1,				\
	  2,0,0}

#define GOLAY_SQ_M_7(VAR)			\
  VAR[9]={0,2,0,				\
	  2,2,0,				\
	  0,0,1}

/////////////////////////////////////////////////////////////
// SQUARE GRID : GOLAY C
/////////////////////////////////////////////////////////////
#define GOLAY_SQ_C_0(VAR)			\
  VAR[9]={2,0,0,				\
	  2,1,0, 				\
	  2,0,0}

#define GOLAY_SQ_C_1(VAR)			\
  VAR[9]={0,2,0,				\
	  2,1,0,				\
	  0,0,0}

#define GOLAY_SQ_C_2(VAR)			\
  VAR[9]={2,2,2,				\
	  0,1,0,				\
	  0,0,0}

#define GOLAY_SQ_C_3(VAR)			\
  VAR[9]={0,2,0,				\
	  0,1,2,				\
	  0,0,0}

#define GOLAY_SQ_C_4(VAR)			\
  VAR[9]={0,0,2,				\
	  0,1,2,				\
	  0,0,2}

#define GOLAY_SQ_C_5(VAR)			\
  VAR[9]={0,0,0,				\
	  0,1,2,				\
	  0,2,0}

#define GOLAY_SQ_C_6(VAR)			\
  VAR[9]={0,0,0,				\
	  0,1,0,				\
	  2,2,2}

#define GOLAY_SQ_C_7(VAR)			\
  VAR[9]={0,0,0,				\
	  2,1,0,				\
	  0,2,0}

/////////////////////////////////////////////////////////////
// SQUARE GRID : GOLAY E
/////////////////////////////////////////////////////////////
#define GOLAY_SQ_E_0(VAR)			\
  VAR[9]={0,0,0,				\
	  1,2,1, 				\
	  1,1,1}

#define GOLAY_SQ_E_1(VAR)			\
  VAR[9]={1,0,0,				\
	  1,2,1,				\
	  1,1,1}

#define GOLAY_SQ_E_2(VAR)			\
  VAR[9]={1,1,0,				\
	  1,2,0,				\
	  1,1,0}

#define GOLAY_SQ_E_3(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,0,				\
	  1,1,0}

#define GOLAY_SQ_E_4(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1, 				\
	  0,0,0}

#define GOLAY_SQ_E_5(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1,				\
	  0,0,1}

#define GOLAY_SQ_E_6(VAR)			\
  VAR[9]={0,1,1,				\
	  0,2,1,				\
	  0,1,1}

#define GOLAY_SQ_E_7(VAR)			\
  VAR[9]={0,1,1,				\
	  0,2,1,				\
	  1,1,1}


/////////////////////////////////////////////////////////////
// SQUARE GRID : GOLAY F
/////////////////////////////////////////////////////////////
#define GOLAY_SQ_F_0(VAR)			\
  VAR[9]={1,1,2,				\
	  2,2,1,				\
	  1,2,1}

#define GOLAY_SQ_F_1(VAR)			\
  VAR[9]={2,1,1,				\
	  1,2,2,				\
	  2,1,1}

#define GOLAY_SQ_F_2(VAR)			\
  VAR[9]={1,2,1,				\
	  2,2,1,				\
	  1,1,2}

#define GOLAY_SQ_F_3(VAR)			\
  VAR[9]={2,1,2,				\
	  1,2,1,				\
	  1,2,1}

#define GOLAY_SQ_F_4(VAR)			\
  VAR[9]={1,2,1,				\
	  1,2,2,				\
	  2,1,1}

#define GOLAY_SQ_F_5(VAR)			\
  VAR[9]={1,1,2,				\
	  2,2,1,				\
	  1,1,2}

#define GOLAY_SQ_F_6(VAR)			\
  VAR[9]={2,1,1,				\
	  1,2,2,				\
	  1,2,1}

#define GOLAY_SQ_F_7(VAR)			\
  VAR[9]={1,2,1,				\
	  1,2,1,				\
	  2,1,2}

/////////////////////////////////////////////////////////////
// SQUARE GRID : GOLAY F2
/////////////////////////////////////////////////////////////
#define GOLAY_SQ_F2_0(VAR)			\
  VAR[9]={2,2,2,				\
	  1,2,1,				\
	  1,1,1}

#define GOLAY_SQ_F2_1(VAR)			\
  VAR[9]={1,2,0,				\
	  1,2,2,				\
	  1,1,1}

#define GOLAY_SQ_F2_2(VAR)			\
  VAR[9]={1,1,2,				\
	  1,2,2,				\
	  1,1,2}

#define GOLAY_SQ_F2_3(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,2,				\
	  1,2,0}

#define GOLAY_SQ_F2_4(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1,				\
	  2,2,2}

#define GOLAY_SQ_F2_5(VAR)			\
  VAR[9]={1,1,1,				\
	  2,2,1,				\
	  0,2,1}

#define GOLAY_SQ_F2_6(VAR)			\
  VAR[9]={2,1,1,				\
	  2,2,1,				\
	  2,1,1}

#define GOLAY_SQ_F2_7(VAR)			\
  VAR[9]={0,2,1,				\
	  2,2,1,				\
	  1,1,1}



/////////////////////////////////////////////////////////////
// SQUARE GRID : GOLAY H
/////////////////////////////////////////////////////////////
#define GOLAY_SQ_H_0(VAR)			\
  VAR[9]={2,2,2,				\
	  2,2,2,				\
	  2,2,2}

#define GOLAY_SQ_H_1(VAR)			\
  VAR[9]={2,2,2,				\
	  2,2,2,				\
	  2,2,2}

#define GOLAY_SQ_H_2(VAR)			\
  VAR[9]={2,2,2,				\
	  2,2,2,				\
	  2,2,2}

#define GOLAY_SQ_H_3(VAR)			\
  VAR[9]={2,2,2,				\
	  2,2,2,				\
	  2,2,2}

#define GOLAY_SQ_H_4(VAR)			\
  VAR[9]={2,2,2,				\
	  2,2,2,				\
	  2,2,2}

#define GOLAY_SQ_H_5(VAR)			\
  VAR[9]={2,2,2,				\
	  2,2,2,				\
	  2,2,2}

#define GOLAY_SQ_H_6(VAR)			\
  VAR[9]={2,2,2,				\
	  2,2,2,				\
	  2,2,2}

#define GOLAY_SQ_H_7(VAR)			\
  VAR[9]={2,2,2,				\
	  2,2,2,				\
	  2,2,2}

/////////////////////////////////////////////////////////////
// SQUARE GRID : GOLAY I
/////////////////////////////////////////////////////////////
#define GOLAY_SQ_I_0(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1,				\
	  1,1,1}

#define GOLAY_SQ_I_1(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1,				\
	  1,1,1}

#define GOLAY_SQ_I_2(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1,				\
	  1,1,1}

#define GOLAY_SQ_I_3(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1,				\
	  1,1,1}

#define GOLAY_SQ_I_4(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1,				\
	  1,1,1}

#define GOLAY_SQ_I_5(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1,				\
	  1,1,1}

#define GOLAY_SQ_I_6(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1,				\
	  1,1,1}

#define GOLAY_SQ_I_7(VAR)			\
  VAR[9]={1,1,1,				\
	  1,2,1,				\
	  1,1,1}















/////////////////////////////////////////////////////////////
// HEXAGON GRID : GOLAY L
/////////////////////////////////////////////////////////////
#define GOLAY_HEX_L_0(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        0,2,0,				\
	    0,   2,2}

#define GOLAY_HEX_L_1(VAR)			\
  VAR[9]= { 0,   0,1,				\
	        2,2,1,				\
	    0,   2,0}

#define GOLAY_HEX_L_2(VAR)			\
  VAR[9]= { 0,   2,0,				\
	        2,2,1,				\
	    0,   0,1}

#define GOLAY_HEX_L_3(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        0,2,0,				\
	    0,   1,1}

#define GOLAY_HEX_L_4(VAR)			\
  VAR[9]= { 0,   0,2,				\
	        1,2,2,				\
	    0,   1,0}

#define GOLAY_HEX_L_5(VAR)			\
  VAR[9]= { 0,   1,0,				\
	        1,2,2,				\
	    0,   0,2}

/////////////////////////////////////////////////////////////
// HEXAGON GRID : GOLAY M
/////////////////////////////////////////////////////////////
#define GOLAY_HEX_M_0(VAR)			\
  VAR[9]= { 0,   2,0,				\
	        2,2,1,				\
	    0,   2,0}

#define GOLAY_HEX_M_1(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        2,2,0,				\
	    0,   0,1}

#define GOLAY_HEX_M_2(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        0,2,2,				\
	    0,   1,0}

#define GOLAY_HEX_M_3(VAR)			\
  VAR[9]= { 0,   0,2,				\
	        1,2,2,				\
	    0,   0,2}

#define GOLAY_HEX_M_4(VAR)			\
  VAR[9]= { 0,   1,0,				\
	        0,2,2,				\
	    0,   2,2}

#define GOLAY_HEX_M_5(VAR)			\
  VAR[9] ={ 0,   0,1,				\
	        2,2,0,				\
	    0,   2,2}

/////////////////////////////////////////////////////////////
// HEXAGON GRID : GOLAY D
/////////////////////////////////////////////////////////////
#define GOLAY_HEX_D_0(VAR)			\
  VAR[9]= { 0,   1,0,				\
	        1,2,2,				\
	    0,   1,0}

#define GOLAY_HEX_D_1(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        1,2,0,				\
	    0,   0,2}

#define GOLAY_HEX_D_2(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        0,2,1,				\
	    0,   2,0}

#define GOLAY_HEX_D_3(VAR)			\
  VAR[9]= { 0,   0,1,				\
	        2,2,1,				\
	    0,   0,1}

#define GOLAY_HEX_D_4(VAR)			\
  VAR[9]= { 0,   2,0,				\
	        0,2,1,				\
	    0,   1,1}

#define GOLAY_HEX_D_5(VAR)			\
  VAR[9] ={ 0,   1,2,				\
	        1,2,0,				\
	    0,   1,0}


/////////////////////////////////////////////////////////////
// HEXAGON GRID : GOLAY C
/////////////////////////////////////////////////////////////
#define GOLAY_HEX_C_0(VAR)			\
  VAR[9]= { 0,   2,0,				\
	        2,1,0,				\
	    0,   2,0}

#define GOLAY_HEX_C_1(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        2,1,0,				\
	    0,   0,0}

#define GOLAY_HEX_C_2(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        0,1,2,				\
	    0,   0,0}

#define GOLAY_HEX_C_3(VAR)			\
  VAR[9]= { 0,   0,2,				\
	        0,1,2,				\
	    0,   0,2}

#define GOLAY_HEX_C_4(VAR)			\
  VAR[9]= { 0,   0,0,				\
	        0,1,2,				\
	    0,   2,2}

#define GOLAY_HEX_C_5(VAR)			\
  VAR[9] ={ 0,   0,0,				\
	        2,1,0,				\
	    0,   2,2}

/////////////////////////////////////////////////////////////
// HEXAGON GRID : GOLAY E
/////////////////////////////////////////////////////////////
#define GOLAY_HEX_E_0(VAR)			\
  VAR[9]= { 0,   0,0,				\
	        1,2,1,				\
	    0,   1,1}

#define GOLAY_HEX_E_1(VAR)			\
  VAR[9]= { 0,   1,0,				\
	        1,2,0,				\
	    0,   1,1}

#define GOLAY_HEX_E_2(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        1,2,0,				\
	    0,   1,0}

#define GOLAY_HEX_E_3(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        1,2,1,				\
	    0,   0,0}

#define GOLAY_HEX_E_4(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        0,2,1,				\
	    0,   0,1}

#define GOLAY_HEX_E_5(VAR)			\
  VAR[9] ={ 0,   0,1,				\
	        0,2,1,				\
	    0,   1,1}

/////////////////////////////////////////////////////////////
// HEXAGON GRID : GOLAY F
/////////////////////////////////////////////////////////////
#define GOLAY_HEX_F_0(VAR)			\
  VAR[9]= { 0,   2,1,				\
	        1,2,2,				\
	    0,   2,1}

#define GOLAY_HEX_F_1(VAR)			\
  VAR[9]= { 0,   1,2,				\
	        2,2,1,				\
	    0,   1,2}

#define GOLAY_HEX_F_2(VAR)			\
  VAR[9]= { 0,   2,1,				\
	        1,2,2,				\
	    0,   2,1}

#define GOLAY_HEX_F_3(VAR)			\
  VAR[9]= { 0,   1,2,				\
	        2,2,1,				\
	    0,   1,2}

#define GOLAY_HEX_F_4(VAR)			\
  VAR[9]= { 0,   2,1,				\
	        1,2,2,				\
	    0,   2,1}

#define GOLAY_HEX_F_5(VAR)			\
  VAR[9]= { 0,   1,2,				\
	        2,2,1,				\
	    0,   1,2}



/////////////////////////////////////////////////////////////
// HEXAGON GRID : GOLAY F2
/////////////////////////////////////////////////////////////
#define GOLAY_HEX_F2_0(VAR)			\
  VAR[9]= { 0,   2,1,				\
	        2,2,1,				\
	    0,   1,1}

#define GOLAY_HEX_F2_1(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        1,2,1,				\
	    0,   1,1}

#define GOLAY_HEX_F2_2(VAR)			\
  VAR[9]= { 0,   1,2,				\
	        1,2,2,				\
	    0,   1,1}

#define GOLAY_HEX_F2_3(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        1,2,2,				\
	    0,   1,2}

#define GOLAY_HEX_F2_4(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        1,2,1,				\
	    0,   2,2}

#define GOLAY_HEX_F2_5(VAR)			\
  VAR[9] ={ 0,   1,1,				\
	        2,2,1,				\
	    0,   2,1}

/////////////////////////////////////////////////////////////
// HEXAGON GRID : GOLAY H
/////////////////////////////////////////////////////////////
#define GOLAY_HEX_H_0(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        2,2,2,				\
	    0,   2,2}

#define GOLAY_HEX_H_1(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        2,2,2,				\
	    0,   2,2}

#define GOLAY_HEX_H_2(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        2,2,2,				\
	    0,   2,2}

#define GOLAY_HEX_H_3(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        2,2,2,				\
	    0,   2,2}

#define GOLAY_HEX_H_4(VAR)			\
  VAR[9]= { 0,   2,2,				\
	        2,2,2,				\
	    0,   2,2}

#define GOLAY_HEX_H_5(VAR)			\
  VAR[9] ={ 0,   2,2,				\
	        2,2,2,				\
	    0,   2,2}

/////////////////////////////////////////////////////////////
// HEXAGON GRID : GOLAY I
/////////////////////////////////////////////////////////////
#define GOLAY_HEX_I_0(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        1,2,1,				\
	    0,   1,1}

#define GOLAY_HEX_I_1(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        1,2,1,				\
	    0,   1,1}

#define GOLAY_HEX_I_2(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        1,2,1,				\
	    0,   1,1}

#define GOLAY_HEX_I_3(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        1,2,1,				\
	    0,   1,1}

#define GOLAY_HEX_I_4(VAR)			\
  VAR[9]= { 0,   1,1,				\
	        1,2,1,				\
	    0,   1,1}

#define GOLAY_HEX_I_5(VAR)			\
  VAR[9] ={ 0,   1,1,				\
	        1,2,1,				\
	    0,   1,1}


   /////////////////////////////////////////////////////////////
  /////////////////////////////////////////////////////////////
#define setSqNhb(dtype,letter)					\
  dtype GOLAY_SQ_##letter##_0(letter0);				\
  dtype GOLAY_SQ_##letter##_1(letter1);				\
  dtype GOLAY_SQ_##letter##_2(letter2);				\
  dtype GOLAY_SQ_##letter##_3(letter3);				\
  dtype GOLAY_SQ_##letter##_4(letter4);				\
  dtype GOLAY_SQ_##letter##_5(letter5);				\
  dtype GOLAY_SQ_##letter##_6(letter6);				\
  dtype GOLAY_SQ_##letter##_7(letter7);				\
								\
  int i;							\
								\
  gl->se = (FLGR_Data2D**) flgr_malloc(sizeof(FLGR_Data2D*)*8);	\
  gl->nbse = 8;							\
								\
  for(i=0 ; i<8 ; i++) {					\
    gl->se[i] = flgr2d_create_##dtype(3,3,1,FLGR_USER_SHAPE,	\
				      FLGR_8_CONNEX);		\
  }								\
  								\
  flgr2d_import_raw_##dtype(gl->se[0],letter0);			\
  flgr2d_import_raw_##dtype(gl->se[1],letter1);			\
  flgr2d_import_raw_##dtype(gl->se[2],letter2);			\
  flgr2d_import_raw_##dtype(gl->se[3],letter3);			\
  flgr2d_import_raw_##dtype(gl->se[4],letter4);			\
  flgr2d_import_raw_##dtype(gl->se[5],letter5);			\
  flgr2d_import_raw_##dtype(gl->se[6],letter6);			\
  flgr2d_import_raw_##dtype(gl->se[7],letter7);			\
								\
  return

  /////////////////////////////////////////////////////////////
  /////////////////////////////////////////////////////////////
#define setHexNhb(dtype,letter)						\
  dtype GOLAY_HEX_##letter##_0(letter0);				\
  dtype GOLAY_HEX_##letter##_1(letter1);				\
  dtype GOLAY_HEX_##letter##_2(letter2);				\
  dtype GOLAY_HEX_##letter##_3(letter3);				\
  dtype GOLAY_HEX_##letter##_4(letter4);				\
  dtype GOLAY_HEX_##letter##_5(letter5);				\
									\
  int i;								\
									\
  gl->se = (FLGR_Data2D**) flgr_malloc(sizeof(FLGR_Data2D*)*6);		\
  gl->nbse = 6;								\
									\
  for(i=0 ; i<6 ; i++) {						\
    gl->se[i] = flgr2d_create_##dtype(3,3,1,FLGR_USER_SHAPE,		\
				      FLGR_6_CONNEX);			\
  }									\
									\
  flgr2d_import_raw_##dtype(gl->se[0],letter0);				\
  flgr2d_import_raw_##dtype(gl->se[1],letter1);				\
  flgr2d_import_raw_##dtype(gl->se[2],letter2);				\
  flgr2d_import_raw_##dtype(gl->se[3],letter3);				\
  flgr2d_import_raw_##dtype(gl->se[4],letter4);				\
  flgr2d_import_raw_##dtype(gl->se[5],letter5);				\
									\
  return


/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
void flgr_fill_square_nhb_golay_L_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_square_nhb_golay_L_fgUINT8(FLGR_Golay *gl) {
  setSqNhb(fgUINT8,L);
}
void flgr_fill_square_nhb_golay_L_fgUINT16(FLGR_Golay *gl) {
  setSqNhb(fgUINT16,L);
}
void flgr_fill_square_nhb_golay_L_fgUINT32(FLGR_Golay *gl) {
  setSqNhb(fgUINT32,L);
}
void flgr_fill_square_nhb_golay_L_fgINT8(FLGR_Golay *gl) {
  setSqNhb(fgINT8,L);
}
void flgr_fill_square_nhb_golay_L_fgINT16(FLGR_Golay *gl) {
  setSqNhb(fgINT16,L);
}
void flgr_fill_square_nhb_golay_L_fgINT32(FLGR_Golay *gl) {
  setSqNhb(fgINT32,L);
}
void flgr_fill_square_nhb_golay_L_fgFLOAT32(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT32,L);
}
void flgr_fill_square_nhb_golay_L_fgFLOAT64(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT64,L);
}


void flgr_fill_hexa_nhb_golay_L_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_hexa_nhb_golay_L_fgUINT8(FLGR_Golay *gl) {
  setHexNhb(fgUINT8,L);
}
void flgr_fill_hexa_nhb_golay_L_fgUINT16(FLGR_Golay *gl) {
  setHexNhb(fgUINT16,L);
}
void flgr_fill_hexa_nhb_golay_L_fgUINT32(FLGR_Golay *gl) {
  setHexNhb(fgUINT32,L);
}
void flgr_fill_hexa_nhb_golay_L_fgINT8(FLGR_Golay *gl) {
  setHexNhb(fgINT8,L);
}
void flgr_fill_hexa_nhb_golay_L_fgINT16(FLGR_Golay *gl) {
  setHexNhb(fgINT16,L);
}
void flgr_fill_hexa_nhb_golay_L_fgINT32(FLGR_Golay *gl) {
  setHexNhb(fgINT32,L);
}
void flgr_fill_hexa_nhb_golay_L_fgFLOAT32(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT32,L);
}
void flgr_fill_hexa_nhb_golay_L_fgFLOAT64(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT64,L);
}


/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
void flgr_fill_square_nhb_golay_M_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_square_nhb_golay_M_fgUINT8(FLGR_Golay *gl) {
  setSqNhb(fgUINT8,M);
}
void flgr_fill_square_nhb_golay_M_fgUINT16(FLGR_Golay *gl) {
  setSqNhb(fgUINT16,M);
}
void flgr_fill_square_nhb_golay_M_fgUINT32(FLGR_Golay *gl) {
  setSqNhb(fgUINT32,M);
}
void flgr_fill_square_nhb_golay_M_fgINT8(FLGR_Golay *gl) {
  setSqNhb(fgINT8,M);
}
void flgr_fill_square_nhb_golay_M_fgINT16(FLGR_Golay *gl) {
  setSqNhb(fgINT16,M);
}
void flgr_fill_square_nhb_golay_M_fgINT32(FLGR_Golay *gl) {
  setSqNhb(fgINT32,M);
}
void flgr_fill_square_nhb_golay_M_fgFLOAT32(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT32,M);
}
void flgr_fill_square_nhb_golay_M_fgFLOAT64(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT64,M);
}


void flgr_fill_hexa_nhb_golay_M_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_hexa_nhb_golay_M_fgUINT8(FLGR_Golay *gl) {
  setHexNhb(fgUINT8,M);
}
void flgr_fill_hexa_nhb_golay_M_fgUINT16(FLGR_Golay *gl) {
  setHexNhb(fgUINT16,M);
}
void flgr_fill_hexa_nhb_golay_M_fgUINT32(FLGR_Golay *gl) {
  setHexNhb(fgUINT32,M);
}
void flgr_fill_hexa_nhb_golay_M_fgINT8(FLGR_Golay *gl) {
  setHexNhb(fgINT8,M);
}
void flgr_fill_hexa_nhb_golay_M_fgINT16(FLGR_Golay *gl) {
  setHexNhb(fgINT16,M);
}
void flgr_fill_hexa_nhb_golay_M_fgINT32(FLGR_Golay *gl) {
  setHexNhb(fgINT32,M);
}
void flgr_fill_hexa_nhb_golay_M_fgFLOAT32(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT32,M);
}
void flgr_fill_hexa_nhb_golay_M_fgFLOAT64(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT64,M);
}


/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
void flgr_fill_hexa_nhb_golay_D_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_hexa_nhb_golay_D_fgUINT8(FLGR_Golay *gl) {
  setHexNhb(fgUINT8,D);
}
void flgr_fill_hexa_nhb_golay_D_fgUINT16(FLGR_Golay *gl) {
  setHexNhb(fgUINT16,D);
}
void flgr_fill_hexa_nhb_golay_D_fgUINT32(FLGR_Golay *gl) {
  setHexNhb(fgUINT32,D);
}
void flgr_fill_hexa_nhb_golay_D_fgINT8(FLGR_Golay *gl) {
  setHexNhb(fgINT8,D);
}
void flgr_fill_hexa_nhb_golay_D_fgINT16(FLGR_Golay *gl) {
  setHexNhb(fgINT16,D);
}
void flgr_fill_hexa_nhb_golay_D_fgINT32(FLGR_Golay *gl) {
  setHexNhb(fgINT32,D);
}
void flgr_fill_hexa_nhb_golay_D_fgFLOAT32(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT32,D);
}
void flgr_fill_hexa_nhb_golay_D_fgFLOAT64(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT64,D);
}

//////////////////////////////////////////
////////////////////////

void flgr_fill_square_nhb_golay_D_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_square_nhb_golay_D_fgUINT8(FLGR_Golay *gl) {
  setSqNhb(fgUINT8,D);
}
void flgr_fill_square_nhb_golay_D_fgUINT16(FLGR_Golay *gl) {
  setSqNhb(fgUINT16,D);
}
void flgr_fill_square_nhb_golay_D_fgUINT32(FLGR_Golay *gl) {
  setSqNhb(fgUINT32,D);
}
void flgr_fill_square_nhb_golay_D_fgINT8(FLGR_Golay *gl) {
  setSqNhb(fgINT8,D);
}
void flgr_fill_square_nhb_golay_D_fgINT16(FLGR_Golay *gl) {
  setSqNhb(fgINT16,D);
}
void flgr_fill_square_nhb_golay_D_fgINT32(FLGR_Golay *gl) {
  setSqNhb(fgINT32,D);
}
void flgr_fill_square_nhb_golay_D_fgFLOAT32(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT32,D);
}
void flgr_fill_square_nhb_golay_D_fgFLOAT64(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT64,D);
}

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
void flgr_fill_square_nhb_golay_E_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_square_nhb_golay_E_fgUINT8(FLGR_Golay *gl) {
  setSqNhb(fgUINT8,E);
}
void flgr_fill_square_nhb_golay_E_fgUINT16(FLGR_Golay *gl) {
  setSqNhb(fgUINT16,E);
}
void flgr_fill_square_nhb_golay_E_fgUINT32(FLGR_Golay *gl) {
  setSqNhb(fgUINT32,E);
}
void flgr_fill_square_nhb_golay_E_fgINT8(FLGR_Golay *gl) {
  setSqNhb(fgINT8,E);
}
void flgr_fill_square_nhb_golay_E_fgINT16(FLGR_Golay *gl) {
  setSqNhb(fgINT16,E);
}
void flgr_fill_square_nhb_golay_E_fgINT32(FLGR_Golay *gl) {
  setSqNhb(fgINT32,E);
}
void flgr_fill_square_nhb_golay_E_fgFLOAT32(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT32,E);
}
void flgr_fill_square_nhb_golay_E_fgFLOAT64(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT64,E);
}


void flgr_fill_hexa_nhb_golay_E_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_hexa_nhb_golay_E_fgUINT8(FLGR_Golay *gl) {
  setHexNhb(fgUINT8,E);
}
void flgr_fill_hexa_nhb_golay_E_fgUINT16(FLGR_Golay *gl) {
  setHexNhb(fgUINT16,E);
}
void flgr_fill_hexa_nhb_golay_E_fgUINT32(FLGR_Golay *gl) {
  setHexNhb(fgUINT32,E);
}
void flgr_fill_hexa_nhb_golay_E_fgINT8(FLGR_Golay *gl) {
  setHexNhb(fgINT8,E);
}
void flgr_fill_hexa_nhb_golay_E_fgINT16(FLGR_Golay *gl) {
  setHexNhb(fgINT16,E);
}
void flgr_fill_hexa_nhb_golay_E_fgINT32(FLGR_Golay *gl) {
  setHexNhb(fgINT32,E);
}
void flgr_fill_hexa_nhb_golay_E_fgFLOAT32(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT32,E);
}
void flgr_fill_hexa_nhb_golay_E_fgFLOAT64(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT64,E);
}


/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
void flgr_fill_square_nhb_golay_C_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_square_nhb_golay_C_fgUINT8(FLGR_Golay *gl) {
  setSqNhb(fgUINT8,C);
}
void flgr_fill_square_nhb_golay_C_fgUINT16(FLGR_Golay *gl) {
  setSqNhb(fgUINT16,C);
}
void flgr_fill_square_nhb_golay_C_fgUINT32(FLGR_Golay *gl) {
  setSqNhb(fgUINT32,C);
}
void flgr_fill_square_nhb_golay_C_fgINT8(FLGR_Golay *gl) {
  setSqNhb(fgINT8,C);
}
void flgr_fill_square_nhb_golay_C_fgINT16(FLGR_Golay *gl) {
  setSqNhb(fgINT16,C);
}
void flgr_fill_square_nhb_golay_C_fgINT32(FLGR_Golay *gl) {
  setSqNhb(fgINT32,C);
}
void flgr_fill_square_nhb_golay_C_fgFLOAT32(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT32,C);
}
void flgr_fill_square_nhb_golay_C_fgFLOAT64(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT64,C);
}


void flgr_fill_hexa_nhb_golay_C_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_hexa_nhb_golay_C_fgUINT8(FLGR_Golay *gl) {
  setHexNhb(fgUINT8,C);
}
void flgr_fill_hexa_nhb_golay_C_fgUINT16(FLGR_Golay *gl) {
  setHexNhb(fgUINT16,C);
}
void flgr_fill_hexa_nhb_golay_C_fgUINT32(FLGR_Golay *gl) {
  setHexNhb(fgUINT32,C);
}
void flgr_fill_hexa_nhb_golay_C_fgINT8(FLGR_Golay *gl) {
  setHexNhb(fgINT8,C);
}
void flgr_fill_hexa_nhb_golay_C_fgINT16(FLGR_Golay *gl) {
  setHexNhb(fgINT16,C);
}
void flgr_fill_hexa_nhb_golay_C_fgINT32(FLGR_Golay *gl) {
  setHexNhb(fgINT32,C);
}
void flgr_fill_hexa_nhb_golay_C_fgFLOAT32(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT32,C);
}
void flgr_fill_hexa_nhb_golay_C_fgFLOAT64(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT64,C);
}


/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
void flgr_fill_square_nhb_golay_H_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_square_nhb_golay_H_fgUINT8(FLGR_Golay *gl) {
  setSqNhb(fgUINT8,H);
}
void flgr_fill_square_nhb_golay_H_fgUINT16(FLGR_Golay *gl) {
  setSqNhb(fgUINT16,H);
}
void flgr_fill_square_nhb_golay_H_fgUINT32(FLGR_Golay *gl) {
  setSqNhb(fgUINT32,H);
}
void flgr_fill_square_nhb_golay_H_fgINT8(FLGR_Golay *gl) {
  setSqNhb(fgINT8,H);
}
void flgr_fill_square_nhb_golay_H_fgINT16(FLGR_Golay *gl) {
  setSqNhb(fgINT16,H);
}
void flgr_fill_square_nhb_golay_H_fgINT32(FLGR_Golay *gl) {
  setSqNhb(fgINT32,H);
}
void flgr_fill_square_nhb_golay_H_fgFLOAT32(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT32,H);
}
void flgr_fill_square_nhb_golay_H_fgFLOAT64(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT64,H);
}


void flgr_fill_hexa_nhb_golay_H_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_hexa_nhb_golay_H_fgUINT8(FLGR_Golay *gl) {
  setHexNhb(fgUINT8,H);
}
void flgr_fill_hexa_nhb_golay_H_fgUINT16(FLGR_Golay *gl) {
  setHexNhb(fgUINT16,H);
}
void flgr_fill_hexa_nhb_golay_H_fgUINT32(FLGR_Golay *gl) {
  setHexNhb(fgUINT32,H);
}
void flgr_fill_hexa_nhb_golay_H_fgINT8(FLGR_Golay *gl) {
  setHexNhb(fgINT8,H);
}
void flgr_fill_hexa_nhb_golay_H_fgINT16(FLGR_Golay *gl) {
  setHexNhb(fgINT16,H);
}
void flgr_fill_hexa_nhb_golay_H_fgINT32(FLGR_Golay *gl) {
  setHexNhb(fgINT32,H);
}
void flgr_fill_hexa_nhb_golay_H_fgFLOAT32(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT32,H);
}
void flgr_fill_hexa_nhb_golay_H_fgFLOAT64(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT64,H);
}


/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
void flgr_fill_square_nhb_golay_I_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_square_nhb_golay_I_fgUINT8(FLGR_Golay *gl) {
  setSqNhb(fgUINT8,I);
}
void flgr_fill_square_nhb_golay_I_fgUINT16(FLGR_Golay *gl) {
  setSqNhb(fgUINT16,I);
}
void flgr_fill_square_nhb_golay_I_fgUINT32(FLGR_Golay *gl) {
  setSqNhb(fgUINT32,I);
}
void flgr_fill_square_nhb_golay_I_fgINT8(FLGR_Golay *gl) {
  setSqNhb(fgINT8,I);
}
void flgr_fill_square_nhb_golay_I_fgINT16(FLGR_Golay *gl) {
  setSqNhb(fgINT16,I);
}
void flgr_fill_square_nhb_golay_I_fgINT32(FLGR_Golay *gl) {
  setSqNhb(fgINT32,I);
}
void flgr_fill_square_nhb_golay_I_fgFLOAT32(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT32,I);
}
void flgr_fill_square_nhb_golay_I_fgFLOAT64(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT64,I);
}


void flgr_fill_hexa_nhb_golay_I_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_hexa_nhb_golay_I_fgUINT8(FLGR_Golay *gl) {
  setHexNhb(fgUINT8,I);
}
void flgr_fill_hexa_nhb_golay_I_fgUINT16(FLGR_Golay *gl) {
  setHexNhb(fgUINT16,I);
}
void flgr_fill_hexa_nhb_golay_I_fgUINT32(FLGR_Golay *gl) {
  setHexNhb(fgUINT32,I);
}
void flgr_fill_hexa_nhb_golay_I_fgINT8(FLGR_Golay *gl) {
  setHexNhb(fgINT8,I);
}
void flgr_fill_hexa_nhb_golay_I_fgINT16(FLGR_Golay *gl) {
  setHexNhb(fgINT16,I);
}
void flgr_fill_hexa_nhb_golay_I_fgINT32(FLGR_Golay *gl) {
  setHexNhb(fgINT32,I);
}
void flgr_fill_hexa_nhb_golay_I_fgFLOAT32(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT32,I);
}
void flgr_fill_hexa_nhb_golay_I_fgFLOAT64(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT64,I);
}

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
void flgr_fill_square_nhb_golay_F_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_square_nhb_golay_F_fgUINT8(FLGR_Golay *gl) {
  setSqNhb(fgUINT8,F);
}
void flgr_fill_square_nhb_golay_F_fgUINT16(FLGR_Golay *gl) {
  setSqNhb(fgUINT16,F);
}
void flgr_fill_square_nhb_golay_F_fgUINT32(FLGR_Golay *gl) {
  setSqNhb(fgUINT32,F);
}
void flgr_fill_square_nhb_golay_F_fgINT8(FLGR_Golay *gl) {
  setSqNhb(fgINT8,F);
}
void flgr_fill_square_nhb_golay_F_fgINT16(FLGR_Golay *gl) {
  setSqNhb(fgINT16,F);
}
void flgr_fill_square_nhb_golay_F_fgINT32(FLGR_Golay *gl) {
  setSqNhb(fgINT32,F);
}
void flgr_fill_square_nhb_golay_F_fgFLOAT32(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT32,F);
}
void flgr_fill_square_nhb_golay_F_fgFLOAT64(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT64,F);
}


void flgr_fill_hexa_nhb_golay_F_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_hexa_nhb_golay_F_fgUINT8(FLGR_Golay *gl) {
  setHexNhb(fgUINT8,F);
}
void flgr_fill_hexa_nhb_golay_F_fgUINT16(FLGR_Golay *gl) {
  setHexNhb(fgUINT16,F);
}
void flgr_fill_hexa_nhb_golay_F_fgUINT32(FLGR_Golay *gl) {
  setHexNhb(fgUINT32,F);
}
void flgr_fill_hexa_nhb_golay_F_fgINT8(FLGR_Golay *gl) {
  setHexNhb(fgINT8,F);
}
void flgr_fill_hexa_nhb_golay_F_fgINT16(FLGR_Golay *gl) {
  setHexNhb(fgINT16,F);
}
void flgr_fill_hexa_nhb_golay_F_fgINT32(FLGR_Golay *gl) {
  setHexNhb(fgINT32,F);
}
void flgr_fill_hexa_nhb_golay_F_fgFLOAT32(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT32,F);
}
void flgr_fill_hexa_nhb_golay_F_fgFLOAT64(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT64,F);
}

/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
void flgr_fill_square_nhb_golay_F2_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_square_nhb_golay_F2_fgUINT8(FLGR_Golay *gl) {
  setSqNhb(fgUINT8,F2);
}
void flgr_fill_square_nhb_golay_F2_fgUINT16(FLGR_Golay *gl) {
  setSqNhb(fgUINT16,F2);
}
void flgr_fill_square_nhb_golay_F2_fgUINT32(FLGR_Golay *gl) {
  setSqNhb(fgUINT32,F2);
}
void flgr_fill_square_nhb_golay_F2_fgINT8(FLGR_Golay *gl) {
  setSqNhb(fgINT8,F2);
}
void flgr_fill_square_nhb_golay_F2_fgINT16(FLGR_Golay *gl) {
  setSqNhb(fgINT16,F2);
}
void flgr_fill_square_nhb_golay_F2_fgINT32(FLGR_Golay *gl) {
  setSqNhb(fgINT32,F2);
}
void flgr_fill_square_nhb_golay_F2_fgFLOAT32(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT32,F2);
}
void flgr_fill_square_nhb_golay_F2_fgFLOAT64(FLGR_Golay *gl) {
  setSqNhb(fgFLOAT64,F2);
}


void flgr_fill_hexa_nhb_golay_F2_fgBIT(FLGR_Golay *gl) {
  flgr_no_define_type_function(FLGR_BIT);
}
void flgr_fill_hexa_nhb_golay_F2_fgUINT8(FLGR_Golay *gl) {
  setHexNhb(fgUINT8,F2);
}
void flgr_fill_hexa_nhb_golay_F2_fgUINT16(FLGR_Golay *gl) {
  setHexNhb(fgUINT16,F2);
}
void flgr_fill_hexa_nhb_golay_F2_fgUINT32(FLGR_Golay *gl) {
  setHexNhb(fgUINT32,F2);
}
void flgr_fill_hexa_nhb_golay_F2_fgINT8(FLGR_Golay *gl) {
  setHexNhb(fgINT8,F2);
}
void flgr_fill_hexa_nhb_golay_F2_fgINT16(FLGR_Golay *gl) {
  setHexNhb(fgINT16,F2);
}
void flgr_fill_hexa_nhb_golay_F2_fgINT32(FLGR_Golay *gl) {
  setHexNhb(fgINT32,F2);
}
void flgr_fill_hexa_nhb_golay_F2_fgFLOAT32(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT32,F2);
}
void flgr_fill_hexa_nhb_golay_F2_fgFLOAT64(FLGR_Golay *gl) {
  setHexNhb(fgFLOAT64,F2);
}




#define setSqNhbDispatchLetter(dtype)			\
  if(strcmp(letter,"L")==0) {				\
    flgr_fill_square_nhb_golay_L_##dtype(gl);		\
    							\
  }else if(strcmp(letter,"M")==0) {			\
    flgr_fill_square_nhb_golay_M_##dtype(gl);		\
 							\
  }else if(strcmp(letter,"C")==0) {			\
    flgr_fill_square_nhb_golay_C_##dtype(gl);		\
							\
  }else if(strcmp(letter,"D")==0) {			\
    flgr_fill_hexa_nhb_golay_D_##dtype(gl);		\
							\
  }else if(strcmp(letter,"E")==0) {			\
    flgr_fill_square_nhb_golay_E_##dtype(gl);		\
							\
  }else if(strcmp(letter,"F")==0) {			\
    flgr_fill_square_nhb_golay_F_##dtype(gl);		\
							\
  }else if(strcmp(letter,"F2")==0) {			\
    flgr_fill_square_nhb_golay_F2_##dtype(gl);		\
							\
  }else if(strcmp(letter,"H")==0) {			\
    flgr_fill_square_nhb_golay_H_##dtype(gl);		\
							\
  }else if(strcmp(letter,"I")==0) {			\
    flgr_fill_square_nhb_golay_I_##dtype(gl);		\
							\
  }else {						\
    POST_ERROR("Unknown Golay Letter : %s\n",letter);	\
    return NULL ;					\
  }


#define setHexNhbDispatchLetter(dtype)			\
  if(strcmp(letter,"L")==0) {				\
    flgr_fill_hexa_nhb_golay_L_##dtype(gl);		\
							\
  }else if(strcmp(letter,"M")==0) {			\
    flgr_fill_hexa_nhb_golay_M_##dtype(gl);		\
							\
  }else if(strcmp(letter,"D")==0) {			\
    flgr_fill_hexa_nhb_golay_D_##dtype(gl);		\
							\
  }else if(strcmp(letter,"C")==0) {			\
    flgr_fill_hexa_nhb_golay_C_##dtype(gl);		\
							\
  }else if(strcmp(letter,"E")==0) {			\
    flgr_fill_hexa_nhb_golay_E_##dtype(gl);		\
							\
  }else if(strcmp(letter,"F")==0) {			\
    flgr_fill_hexa_nhb_golay_F_##dtype(gl);		\
							\
  }else if(strcmp(letter,"F2")==0) {			\
    flgr_fill_hexa_nhb_golay_F2_##dtype(gl);		\
							\
  }else if(strcmp(letter,"H")==0) {			\
    flgr_fill_hexa_nhb_golay_H_##dtype(gl);		\
							\
  }else if(strcmp(letter,"I")==0) {			\
    flgr_fill_hexa_nhb_golay_I_##dtype(gl);		\
							\
  }else {						\
    POST_ERROR("Unknown Golay Letter : %s\n",letter);	\
    return NULL ;					\
  }




////////////////////////////////////////////////////////////////////////////
/*! Set a golay letter in a neighborhood definition<BR>
 *  Golay letter could be : "L", "M", "C", "D", "E", "F", "F2", "F3", "H", "I"
 *
 *  Values set inside the neighborhood are:
 *  <ul>
 *  <li>0 : not tested</li>
 *  <li>1 : background</li>
 *  <li>2 : foreground</li>
 *  </ul>
 *
 *  @param letter : a string for golay letter
 *  @param connexity : connexity of SE (6 or 8)
 *  @param type : type of SE
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Golay* flgr2d_create_golay(char *letter, FLGR_Type type, FLGR_Connexity connexity) {

  FLGR_DECLARE_FUNCTION;

  FLGR_Golay *gl = flgr_malloc(sizeof(FLGR_Golay));

  if(connexity == FLGR_8_CONNEX) {

    if(type == FLGR_UINT8) {
      setSqNhbDispatchLetter(fgUINT8);

    }else if(type == FLGR_UINT16) {
      setSqNhbDispatchLetter(fgUINT16);

    }else if(type == FLGR_UINT32) {
      setSqNhbDispatchLetter(fgUINT32);

    }else if(type == FLGR_INT8) {
      setSqNhbDispatchLetter(fgINT8);

    }else if(type == FLGR_INT16) {
      setSqNhbDispatchLetter(fgINT16);

    }else if(type == FLGR_INT32) {
      setSqNhbDispatchLetter(fgINT32);

    }else if(type == FLGR_FLOAT32) {
      setSqNhbDispatchLetter(fgFLOAT32);

    }else if(type == FLGR_FLOAT64) {
      setSqNhbDispatchLetter(fgFLOAT64);

    }else if(type == FLGR_BIT) {
      setSqNhbDispatchLetter(fgBIT);

    }else {
      POST_ERROR("type unknown!\n");
      return NULL;

    }

  }else if(connexity== FLGR_6_CONNEX) {

    if(type == FLGR_UINT8) {
      setHexNhbDispatchLetter(fgUINT8);

    }else if(type == FLGR_UINT16) {
      setHexNhbDispatchLetter(fgUINT16);

    }else if(type == FLGR_UINT32) {
      setHexNhbDispatchLetter(fgUINT32);

    }else if(type == FLGR_INT8) {
      setHexNhbDispatchLetter(fgINT8);

    }else if(type == FLGR_INT16) {
      setHexNhbDispatchLetter(fgINT16);

    }else if(type == FLGR_INT32) {
      setHexNhbDispatchLetter(fgINT32);

    }else if(type == FLGR_FLOAT32) {
      setHexNhbDispatchLetter(fgFLOAT32);

    }else if(type == FLGR_FLOAT64) {
      setHexNhbDispatchLetter(fgFLOAT64);

    }else if(type == FLGR_BIT) {
      setHexNhbDispatchLetter(fgBIT);

    }else {
      POST_ERROR("type unknown!\n");
      return NULL;

    }

  }else {
    POST_ERROR("Connexity not available for Golay letter : %d\n",connexity);
    return NULL;

  }

  return gl;

}



void flgr2d_destroy_golay(FLGR_Golay* gl) {
  int i;

  for(i=0 ; i<gl->nbse ; i++) {
    flgr2d_destroy(gl->se[i]);				
  }

  flgr_free(gl->se); 
  
}



//! @}
